#include <stdio.h>
#include <stdlib.h>

#define STDIN
//#define DEBUG

#define MAXN 101

int n;
int wall[MAXN];

#define min(a, b) (a) > (b) ? (b) : (a)

int compare(void* a, void* b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
#ifdef STDIN
    freopen("bin/1477.in", "r", stdin);
#endif

    int i;
    int sum = 0, everage=0;
    int mv_cnt = 0;
    int test_case = 0;

    while(scanf("%d", &n) && n){
        test_case++;

        sum = everage = 0;
        mv_cnt = 0;
        for (i = 0; i < n; ++i){
            scanf("%d", wall+i);
            sum += wall[i];
        }

        everage = sum / n;

        for (i = 0; i < n; ++i){
            wall[i] -= everage;
        }

        int max, min;
        int max_i,min_i;
        while(1)
        {
#ifdef DEBUG
            for (i = 0; i < n; ++i)
                printf("%d\t", wall[i]);
            printf("\n");
#endif
            max = min = 0;
            max_i = min_i = 0;
            for (i = 0; i < n; ++i)
            {
                if (wall[i] < min){
                    min = wall[i];
                    min_i = i;
                    continue;
                }
                if (wall[i] > max) {
                    max = wall[i];
                    max_i = i;
                    continue;
                }
            }
            if (( max | min) == 0)
                break;
            mv_cnt += min(-wall[min_i], wall[max_i]);
            wall[min_i] += wall[max_i];
            wall[max_i] = 0;
        }
        printf("Set #%d\n", test_case);
        printf("The minimum number of moves is %d.\n", mv_cnt);
        printf("\n");
    }

    return 0;
}
